<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ include file="/includes/taglibs.jsp" %>
<html>
<head>
<title>糗事百科</title>
<%@ include file="/includes/meta.jsp" %>
<script src="${ctx}/resource/scripts/jquery.lazyload.min.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
	jQuery("img").lazyload({ 
		threshold : 200 ,
		effect : "fadeIn"
	});
});
function submitOpt(postId,toUp,toDown,object){
	jQuery.ajax({
	   type: "POST",
	   url: "${ctx}/abash/upordown/save",
	   data: "postId="+postId+"&toUp="+toUp+"&toDown="+toDown+"&operatorId="+${user.id},
	   dataType:'json',
	   success:function(res){
	   		if (toUp){jQuery(object).text("顶:"+res.toUpNum);}
	   		if (toDown){jQuery(object).text("拍:"+res.toDownNum);}
	   }
	}); 
}
</script>
</head>
<body>
<a href="${ctx}/abash/dayhot/1">今天热门</a> &nbsp;
<a href="${ctx}/abash/weekhot/1">本周热门</a> &nbsp;
<a href="${ctx}/abash/monthhot/1">本月热门</a> &nbsp;
<a href="${ctx}/abash/yearhot/1">今年热门</a> &nbsp;
<a href="${ctx}/abash/allhot/1">所有热门</a> &nbsp;
<a href="${ctx}/abash/imagehot/1">有图有真相</a> &nbsp;
<a href="${ctx}/abash/newposts/1">最新</a> &nbsp;&nbsp;
<a href="${ctx}/abash/post/new">新增</a> &nbsp;
<table>
  <c:forEach items="${page.data}" var="abash">
  <tr>
    <td>发布人:${users[abash.authorId].realName}</td>
  </tr>
   <tr>
    <td>
    	${abash.content}<br>
    	<c:if test="${not empty abash.images}">
    		<c:forEach items="${abash.images}"  var="imageId">
    			<img src="${ctx}/abash/images/${imageId}" style="width:10%">
    		</c:forEach>
    	</c:if>
    </td>
  </tr>
   <tr>
    <td>
    	<a href="#" onclick="submitOpt(${abash.id},true,false,this);">顶:${abash.toUpNum}</a> &nbsp;&nbsp;
    	<a href="#" onclick="submitOpt(${abash.id},false,true,this);">拍:${abash.toDownNum}</a> &nbsp;&nbsp;
    	<a href="${ctx}/abash/post/view/${abash.id}">回复:${abash.replyNum}</a>
    </td>
  </tr>
  </c:forEach>
  <tr>
  	<td>
  		<!--翻页--->
  		<form name="frm" id="frm" method="post">  
	  		<jsp:include page="/includes/page_rest.jsp">
	  			<jsp:param name="formName" value="frm" />
	  			<jsp:param name="formAction" value="${ctx}${formAction}" />
		  	</jsp:include>
	  	</form>
  	</td>
  </tr>
</table>
</body> 
</html>  